/*
 *	公共操作函数
 */

window.$conf={
	msg_model				: 1,						//弹窗口模式  0=经典 1=swal 2=notiflix 3=layui
	all_sel					:'all_ck',					//全选控件名
	sel_att					:'ckbox',					//子复选组属性
	input_sel				:'ctrla',					//点击选择文本内容
	invert					:'invert_ck',				//反选
	data_att				:'data',					//数据参数属性名
	code_name				:'#code_img',				//验证码图片ID	
	enter					:'enter',					//控件回车属性
	page_select				:'#page_select'				//分页下拉菜单ID
}

layui.use(['table', 'form', 'jquery','common','laydate'], function() {
	
});
//-------------------------------------【页面特效】

function p(res){
	console.log(res);
}
function Alert(msg,show_type='info',times=0,callback=null){									//弹出对话框
	//show_type   info=信息   success=成功   error=错误  warning=警告
	times=times*1000;
	if($conf.msg_model==1){
		if(show_type!=''){
			conf={
				title: msg,
				icon: show_type,
				confirmButtonText:'确定',
			}
		}else{
			conf={
				title: msg,
				html: true,
				confirmButtonText:'确定',
			}
		}
		if(times!=0){
			conf.timer=times;
		}
		Swal.fire(conf).then((result) => {
			(callback && typeof(callback) === "function") && callback();  
		})
	}else if($conf.msg_model==2){
		switch(show_type){
			case 'success':
				Notiflix.Report.Success(msg, '', '确定'); 
				break;
			case 'error':
				Notiflix.Report.Failure(msg, '', '确定'); 
				break;
			case 'warning':
				Notiflix.Report.Warning(msg, '', '确定'); 
				break;
			default:
				Notiflix.Report.Info(msg, '', '确定'); 
				break;
		}
	}else if($conf.msg_model==3){
		switch(show_type){
			case 'success':
				layer.msg(msg,{time:times,icon:6},callback); 
				break;
			case 'error':
				layer.msg(msg,{time:times,icon:2},callback); 
				break;
			case 'warning':
				layer.msg(msg,{time:times,icon:0},callback); 
				break;
			default:
				layer.msg(msg,{time:times,icon:0},callback); 
				break;
		}
	}else{
		alert(msg);
	}
}

// 加载Load 请确保加载 Notiflix
function load_show(message,type=2){
	switch(type){
		case 1:
			Notiflix.Loading.Standard(message);
			break;
		case 2:
			Notiflix.Loading.Hourglass(message);
			break;
		case 3:
			Notiflix.Loading.Circle(message);
			break;
		case 4:
			Notiflix.Loading.Arrows(message);
			break;
		case 5:
			Notiflix.Loading.Dots(message);
			break;
		case 6:
			Notiflix.Loading.Pulse(message);
			break;
	}
}

// 移除Load 请确保加载 Notiflix
function load_hide(){
	Notiflix.Loading.Remove();
}

// 提示框选择框
function confirmed(msg,$confirm,$cancel){
	if($conf.msg_model==1){
		var conf={
			title: msg,
			icon: "warning",
			showCancelButton: true,
			cancelButtonText:'取消',
			confirmButtonColor: '#DD6B55',
			confirmButtonText: '确定',
			closeOnConfirm: false
		}
		Swal.fire(conf).then((result)=>{
			if (result.isConfirmed) {
				($confirm && typeof($confirm) === "function") && $confirm();
			}else{
				($cancel && typeof($cancel) === "function") && $cancel();
			}
		});
	}else if($conf.msg_model==2){
	}else if($conf.msg_model==3){
		layer.confirm(msg,{
			icon: 3,
			title: '温馨提示'
		}, function(index) {
			($confirm && typeof($confirm) === "function") && $confirm(index);
		}, function(index) {
			($cancel && typeof($cancel) === "function") && $cancel(index);
		});
	}
}

//获取自定义Input参数，请用fun返回值判断
function input_conf(msg){
	return {
		title: msg,
		//text: '请输入信息:',
		type: 'input',
		showCancelButton: true,
		cancelButtonText:'取消',
		confirmButtonText: '确定',
		closeOnConfirm: false,
		animation: "slide-from-top"
	}
}